$(function(){
  //菜单点击
  $(".J_menuItem").on('click', function () {
    var thisParent = $(this).context.parentNode;
    $(thisParent).addClass('active');
    $(thisParent).siblings().removeClass('active');
    // console.log($(thisParent).siblings().find('li').hasClass('active'));
    // console.log($($(thisParent).context.parentNode).siblings().find('li').hasClass('active'));
    var url = $(this).attr('href');
    $("#J_iframe").attr('src', url);
    $("#current_page_title").html('当前页：' + $(this).text());
    return false;
  })

  // 头部搜索框
  var shouldHide = true;
  $searchList = $('#search-result');
  $('#global-search').focus(function() {
    $searchList.css('display', 'block');
  });
  $('#global-search').blur(function() {
    shouldHide && $searchList.hide();
  });

  $('.navbar-form-custom').on('mouseenter', 'ul', function() {
    shouldHide = false;
  })

  $('.navbar-form-custom').on('mouseleave', 'ul', function() {
    shouldHide = true;
  })

  $('.navbar-form-custom').on('click', 'ul li', function() {
    var url = $(this).attr('href');
    $("#J_iframe").attr('src',url);
    $searchList.hide();
    return false;
  })

});